package com.songlanyun.modules.order.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.songlanyun.common.drive.RootEntity;
import com.songlanyun.common.utils.SpringContextUtils;
import com.songlanyun.modules.account.entity.UserInfoEntity;
import com.songlanyun.modules.account.service.UserInfoService;
import com.songlanyun.modules.order.service.ChildOrderService;
import com.songlanyun.modules.order.service.ChildOrderServiceItemService;
import com.songlanyun.modules.rabbitmq.util.SpringContextUtil;
import lombok.Data;

import javax.validation.constraints.Null;

/**
 * 服务商品预约记录
 *
 * @author wuchao
 * @email sunlightcs@gmail.com
 * @date 2021-03-19 13:54:17
 */
@Data
@TableName("yxt_service_goods_reservation_record")
public class ReservationRecordEntity extends RootEntity<Long, ReservationRecordEntity> implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     *
     */
    @TableId
    private Long id;
    /**
     * 会员id
     */
    private Long userId;

    /**
     * 会员昵称
     */
    private String nickname;

    /**
     * 会员手机号
     */
    private String mobile;
    /**
     * 商家id
     */
    private Long shopId;
    /**
     * 服务商品id
     */
    private Long serviceGoodsId;
    /**
     * 订单id
     */
    private Long orderId;
    /**
     * 子订单id
     */
    private Long childOrderId;

    /**
     * 主订单下面的子订单
     */
    @TableField(exist = false)
    private List<ChildOrder> childOrderList;

    public List<ChildOrder> getChildOrderList() {

        ChildOrderService childOrderService = (ChildOrderService) SpringContextUtil.getBean("childOrderService");
        childOrderList = childOrderService.list(new LambdaQueryWrapper<ChildOrder>().eq(ChildOrder::getOrderId, this.getOrderId()));
        return childOrderList;
    }

    /**
     * 订单编号
     */
    private String orderCode;


    /**
     * 预约时间
     */
    private Date appointmentTime;
    /**
     * 客户要求
     */
    @TableField("`require`")
    private String require;
    /**
     * 登记人
     */
    private Long registrant;
    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @Override
    public Long getIdentity() {
        return this.getId();
    }
}
